package com.ndp.fb.enums.targetingspec;

import lombok.Getter;

/**
 * Created by Sisi on 14-11-14.
 */
@Getter
public enum WirelessCarrier {
    Wifi(1, "Wifi", "Wi-Fi"),
    AllMobileUsers(0, "AllMobileUsers", "AllMobileUsers");

    private int code;

    private String wirelessCarrier;

    private String showWirelessCarrier;

    WirelessCarrier(int code, String wirelessCarrier, String showWirelessCarrier) {
        this.code = code;
        this.wirelessCarrier = wirelessCarrier;
        this.showWirelessCarrier = showWirelessCarrier;
    }

    /**
     * 根据code获取WirelessCarrier
     *
     * @param code code
     * @return WirelessCarrier
     */
    public static WirelessCarrier getWirelessCarrier(int code) {
        for (WirelessCarrier c : WirelessCarrier.values()) {
            if (c.code == code) {
                return c;
            }
        }
        return null;
    }

    /**
     * 根据wirelessCarrier获取wirelessCarrier
     *
     * @param wirelessCarrier wirelessCarrier
     * @return wirelessCarrier
     */
    public static WirelessCarrier getWirelessCarrier(String wirelessCarrier) {
        for (WirelessCarrier c : WirelessCarrier.values()) {
            if (c.wirelessCarrier.equals(wirelessCarrier)) {
                return c;
            }
        }
        return null;
    }
}
